package com.kingdee.pda.ui.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.basecommon.utils.SpeakUtils;
import com.kingdee.pda.R;
import com.kingdee.pda.adapter.MoveLocationAdapter;
import com.kingdee.pda.commonmethod.CheckSkuPresenter;
import com.kingdee.pda.commonmethod.CheckSkuView;
import com.kingdee.pda.commonmethod.QueryStockPresenter;
import com.kingdee.pda.commonmethod.QueryStockView;
import com.kingdee.pda.entity.Goods;
import com.kingdee.pda.entity.LocationListBean;
import com.kingdee.pda.entity.Warehouse;
import com.kingdee.pda.entity.WarehouseLocation;
import com.kingdee.pda.plugins.http.common.OnRequestCallback;
import com.kingdee.pda.plugins.http.serverinterface.IMoveOperate;
import com.kingdee.pda.plugins.http.serverinterface.impl.MoveOperateImpl;
import com.kingdee.pda.ui.dialog.RemindDialog;
import com.kingdee.pda.ui.goods_putaway.OwnerBean;
import com.kingdee.pda.ui.popupwindow.ListSelectorPpWindow;
import com.kingdee.pda.ui.widget.InScrollListView;
import com.kingdee.pda.util.CommonUtil;
import com.kingdee.pda.util.GlideUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 库内移动操作
 * Created by zhanlg
 * DATE 2021/5/26
 * TIME 11:13
 */
public class MoveInWarehouseActivity extends BaseTitleActivity implements QueryStockView, CheckSkuView {

    private TextView mTvErrorTips;
    private EditText mEtMoveOutLocation;
    private EditText mEtGoodsBarcode;
    private EditText mEtMoveInLocation;
    private EditText mEtMoveCount;
    private EditText et_invStatusName;
    private EditText et_owner;
    private TextView mTvMoveCountTips;
    private ImageView mIvGoodsPic;
    private TextView mTvSkuNum;
    private TextView mTvSkuName;
    private TextView mTvGoodsBarcode;
    private TextView mTvNoDataTips;
    private InScrollListView mListView;
    private Button mBtnConfirm;
    private WarehouseLocation mMoveOutLocation;//移出库位信息
    private WarehouseLocation mMoveInLocation;// 移入库位信息
    private Goods mOperateGoods;//商品操作对象
    private RemindDialog mOperateConfirmDialog;
    private RemindDialog mResultRemindDialog;
    private List<WarehouseLocation> mGoodsLocaitonList;//商品库位信息列表
    private MoveLocationAdapter mAdapter;
    private int mCanMoveQty = 0;//可移动数量
    private QueryStockPresenter queryStockPresenter;
    private boolean isMoveOut;
    private CheckSkuPresenter checkSkuPresenter;
    private List<LocationListBean> locationListBeanList = new ArrayList<>();
    //货主集合
    private List<OwnerBean> ownerBeanList = new ArrayList<>();


    public static void actionStart(Context context) {
        context.startActivity(new Intent(context, MoveInWarehouseActivity.class));
    }

    @Override
    protected void onActivityCreate(Bundle savedInstanceState) {
        super.onActivityCreate(savedInstanceState);
        setContentView(R.layout.activity_move_in_warehouse);
    }

    @Override
    protected void initView() {
        super.initView();
        setTitle("库内移动");
        mTvErrorTips = findViewById(R.id.tv_error_tips);
        mEtMoveOutLocation = findViewById(R.id.et_move_out_location);
        mEtGoodsBarcode = findViewById(R.id.et_goods_barcode);
        mEtMoveInLocation = findViewById(R.id.et_move_in_location);
        mEtMoveCount = findViewById(R.id.et_move_count);
        mTvMoveCountTips = findViewById(R.id.tv_move_count_tips);
        mIvGoodsPic = findViewById(R.id.iv_goods_pic);
        mTvSkuNum = findViewById(R.id.tv_sku_num);
        mTvSkuName = findViewById(R.id.tv_sku_name);
        mTvGoodsBarcode = findViewById(R.id.tv_goods_barcode);
        mTvNoDataTips = findViewById(R.id.tv_no_data_tips);
        mListView = findViewById(R.id.list_view);
        mBtnConfirm = findViewById(R.id.btn_confirm);
        et_invStatusName = findViewById(R.id.et_invStatusName);
        et_owner = findViewById(R.id.et_owner);

        findViewById(R.id.iv_select_invStatusName).setOnClickListener(this);
        findViewById(R.id.iv_select_owner).setOnClickListener(this);
        findViewById(R.id.iv_lcoation_in_select).setOnClickListener(this);
        mBtnConfirm.setOnClickListener(this);
        mEtMoveOutLocation.setOnFocusChangeListener(new EditTextFocusListener());
        mEtGoodsBarcode.setOnFocusChangeListener(new EditTextFocusListener());
        mEtMoveInLocation.setOnFocusChangeListener(new EditTextFocusListener());
        mEtMoveCount.setOnFocusChangeListener(new EditTextFocusListener());
        mEtMoveOutLocation.setOnEditorActionListener(new OnActionListener());
        mEtGoodsBarcode.setOnEditorActionListener(new OnActionListener());
        mEtMoveInLocation.setOnEditorActionListener(new OnActionListener());
        addMoveCountEditChangeListener();

        queryStockPresenter = new QueryStockPresenter(this, this);
        checkSkuPresenter = new CheckSkuPresenter(this, this);

    }

    @Override
    protected void initData() {
        super.initData();
        mGoodsLocaitonList = new ArrayList<>();
        mAdapter = new MoveLocationAdapter(this);
        mListView.setAdapter(mAdapter);
    }

    /**
     * 展示货主选择框
     */
    private void showOwnerSelector() {
        ListSelectorPpWindow<OwnerBean> locationSelector = new ListSelectorPpWindow<>(this,
                R.drawable.shape_bg_edit_selected,
                et_owner.getWidth(),
                ownerBeanList,
                new ListSelectorPpWindow.onItemSelectedListener() {
                    @Override
                    public void onItemSelected(Object item) {
                        OwnerBean ownerBean = ((OwnerBean) item);
                        for (LocationListBean bean : locationListBeanList) {
                            if (ownerBean.getOwner() == bean.getOwner()) {
                                mMoveOutLocation.setSelectedStatusBean(bean);
                                break;
                            }
                        }
                        mMoveOutLocation.setSelectedOwnerBean(ownerBean);
                        et_owner.setText(ownerBean.getOwnerName());
                        calculateCanMoveQty();
                        mAdapter.notifyDataSetChanged();
                    }
                });
        locationSelector.showAsDropDown(et_owner, 0, 10);
    }


    @Override
    public void queryWarehouseLocationSuccess(WarehouseLocation warehouseLocation) {
        if (isMoveOut) {
            mMoveOutLocation = warehouseLocation;
            mEtGoodsBarcode.requestFocus();
        } else {
            mMoveInLocation = warehouseLocation;
            queryGoodsLocationStock(mMoveInLocation);
        }
    }

    @Override
    public void queryWarehouseLocationFailed(String message) {
        showErrorTips(message);
        if (isMoveOut) {
            mEtMoveOutLocation.setText("");
            mMoveOutLocation = null;
        } else {
            mEtMoveInLocation.setText("");
            mMoveInLocation = null;
        }
    }

    @Override
    public void queryGoodsSuccess(Goods goods) {
        mOperateGoods = goods;
        showGoodsView();
        isMoveOut = true;
        queryGoodsLocationStock(mMoveOutLocation);
    }

    @Override
    public void queryGoodsFailed(String message) {
        showErrorTips(message);
        CommonUtil.requestFocusAndClearText(mEtGoodsBarcode);
        initGoodsView();
    }

    @Override
    public void queryGoodsLocationStockSuccess(WarehouseLocation warehouseLocation) {
        mGoodsLocaitonList.clear();

        if (isMoveOut) {
            ownerBeanList.clear();
            mMoveOutLocation = warehouseLocation;
            mMoveOutLocation.setMoveOut(true);
            mGoodsLocaitonList.add(mMoveOutLocation);
            //获取库存状态并展示
            locationListBeanList.clear();
            locationListBeanList.addAll(mMoveOutLocation.getList());

            //循环所有的库存数据
            for (LocationListBean bean : mMoveOutLocation.getList()) {
                //判断此货主是否已添加
                boolean isAddOwner = false;
                for (OwnerBean owner : ownerBeanList) {
                    if (owner.getOwner() == bean.getOwner()) {
                        isAddOwner = true;
                    }
                }
                if (!isAddOwner) {
                    ownerBeanList.add(new OwnerBean(bean.getOwnertype(), bean.getOwner(), bean.getOwnerName()));
                }
            }

            //默认选中第一个状态
            if (locationListBeanList.size() > 0) {
                mMoveOutLocation.setSelectedStatusBean(locationListBeanList.get(0));
                et_invStatusName.setText(mMoveOutLocation.getSelectedStatusBean().getInvStatusName());
            }

            //默认选中第一个货主
            if (ownerBeanList.size() > 0) {
                mMoveOutLocation.setSelectedOwnerBean(ownerBeanList.get(0));
                et_owner.setText(mMoveOutLocation.getSelectedOwnerBean().getOwnerName());
            }

        } else {
            mMoveInLocation = warehouseLocation;
            mMoveInLocation.setMoveOut(false);
            mGoodsLocaitonList.add(mMoveOutLocation);
            mGoodsLocaitonList.add(mMoveInLocation);
            calculateCanMoveQty();
        }

        mTvNoDataTips.setVisibility(View.GONE);
        mListView.setVisibility(View.VISIBLE);
        mAdapter.setData(mGoodsLocaitonList);
    }

    @Override
    public void queryGoodsLocationStockFailed(String message) {
        showErrorTips(message);
    }

    class EditTextFocusListener implements EditText.OnFocusChangeListener {

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (v instanceof EditText) {
                EditText editText = ((EditText) v);
                if (hasFocus) {
                    editText.setBackgroundResource(R.drawable.shape_bg_edit_selected);
                    editText.setSelection(editText.getText().length());
                } else {
                    editText.setBackgroundResource(R.drawable.dialog_edit_bg);
                }
            }
        }
    }

    class OnActionListener implements TextView.OnEditorActionListener {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_ACTION_NEXT || (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
                String input = v.getText().toString().trim();
                if (TextUtils.isEmpty(input)) {
                    showErrorTips("输入为空！");
                    return true;
                }
                if (!checkCurrentWarehouse()) {
                    return true;
                }
                switch (v.getId()) {
                    case R.id.et_move_out_location:
                        clearAllView();
                        mEtMoveOutLocation.setText(input);
                        queryLocationInfo(input, true);
                        break;
                    case R.id.et_goods_barcode:
                        if (mMoveOutLocation == null) {
                            showErrorTips("请选择移出库位！");
                            return true;
                        }
                        String skuSplit = CommonUtil.skuCodeSplit(MoveInWarehouseActivity.this, input);
                        if (TextUtils.isEmpty(skuSplit)) {
                            SpeakUtils.speakWithToast(MoveInWarehouseActivity.this, "商品条码截取结果为空，请检查输入和截图规则", false, false);
                            return true;
                        }
                        queryGoodsInfo(skuSplit);
                        break;
                    case R.id.et_move_in_location:
                        if (mOperateGoods == null) {
                            showErrorTips("请先扫描或录入商品！");
                            return true;
                        }
                        if (input.equals(mEtMoveOutLocation.getText().toString().trim())) {
                            showErrorTips("移入库位不可与移出库位相同");
                            return true;
                        }
                        queryLocationInfo(input, false);
                        break;
                }
                return true;
            }
            return false;
        }
    }

    private void addMoveCountEditChangeListener() {
        mEtMoveCount.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                int input = CommonUtil.formatStringToInt(mEtMoveCount.getText().toString().trim());
                if (input > mCanMoveQty) {
                    mEtMoveCount.setText(String.valueOf(mCanMoveQty));
                    mEtMoveCount.setSelection(mEtMoveCount.getText().length());
                }
            }
        });
    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()) {
            case R.id.btn_confirm:
                confirmClick();
                break;
            case R.id.iv_select_invStatusName:
//                showInvStatusNameSelector();
                break;
            case R.id.iv_select_owner:
                showOwnerSelector();
                break;
        }
    }

    @Override
    public void changeWarehouse(Warehouse warehouse) {
        //切换仓库，清除页面所有信息
        clearAllView();
    }

    @Override
    public void getScanResult(String scanResult) {
        super.getScanResult(scanResult);
        if (TextUtils.isEmpty(scanResult)) {
            showErrorTips("扫码识别错误！");
            return;
        }
        if (!checkCurrentWarehouse()) {
            return;
        }
        View view = getWindow().getCurrentFocus();
        if (view instanceof EditText) {
            switch (view.getId()) {
                case R.id.et_move_out_location:
                    clearAllView();
                    mEtMoveOutLocation.setText(scanResult);
                    queryLocationInfo(scanResult, true);
                    break;
                case R.id.et_goods_barcode:
                    if (mMoveOutLocation == null) {
                        showErrorTips("请选择移出库位！");
                        return;
                    }
                    String skuSplit = CommonUtil.skuCodeSplit(MoveInWarehouseActivity.this, scanResult);
                    if (TextUtils.isEmpty(skuSplit)) {
                        SpeakUtils.speakWithToast(MoveInWarehouseActivity.this, "商品条码截取结果为空，请检查输入和截图规则", false, false);
                        return;
                    }
                    mEtGoodsBarcode.setText(skuSplit);
                    queryGoodsInfo(skuSplit);
                    break;
                case R.id.et_move_in_location:
                    if (mOperateGoods == null) {
                        showErrorTips("请先扫描或录入商品！");
                        return;
                    }
                    if (scanResult.equals(mEtMoveOutLocation.getText().toString().trim())) {
                        showErrorTips("移入库位不可与移出库位相同");
                        return;
                    }
                    mEtMoveInLocation.setText(scanResult);
                    queryLocationInfo(scanResult, false);
                    break;
            }
        }
    }

    private void showErrorTips(String tips) {
        mTvErrorTips.setText(tips);
        mTvErrorTips.setVisibility(View.VISIBLE);
        postDelayGone();
    }

    private void postDelayGone() {
        mTvErrorTips.postDelayed(new Runnable() {
            @Override
            public void run() {
                mTvErrorTips.setVisibility(View.GONE);
            }
        }, 3000);
    }

    private boolean checkCurrentWarehouse() {
        if (getCurrentWarehouse() == null) {
            showErrorTips("请先设置当前仓库！");
            return false;
        }
        return true;
    }

    /**
     * 查询库位信息
     *
     * @param locationNum 库位编码
     * @param isMoveOut   是否为移出仓库
     */
    private void queryLocationInfo(String locationNum, final boolean isMoveOut) {
        this.isMoveOut = isMoveOut;
        queryStockPresenter.queryWarehouseLocation(getCurrentWarehouse().getId(), locationNum);
    }

    private void queryGoodsInfo(String barcode) {
        checkSkuPresenter.queryGoods(getCurrentWarehouse().getId(), mMoveOutLocation.getLocationId(), barcode);
    }


    private void queryGoodsLocationStock(WarehouseLocation location) {
        queryStockPresenter.queryGoodsLocationStock(location, mOperateGoods.getSkuId(), 0);
    }

    private void initGoodsView() {
        mIvGoodsPic.setImageResource(R.mipmap.image_pic_default);
        mTvSkuNum.setText("SKU 编码：—");
        mTvSkuName.setText("SKU 名称：—");
        mTvGoodsBarcode.setText("商品条码：—");
    }

    private void showGoodsView() {
        GlideUtils.loadImage(MoveInWarehouseActivity.this, mOperateGoods.getPictureUrl(), mIvGoodsPic);
        mTvSkuNum.setText("SKU 编码：" + mOperateGoods.getSkuCode());
        mTvSkuName.setText("SKU 名称：" + mOperateGoods.getSpecName());
        mTvGoodsBarcode.setText("商品条码：" + mOperateGoods.getItemBarcode());
        mEtMoveInLocation.requestFocus();
    }

    private void calculateCanMoveQty() {
        if (mMoveOutLocation == null || mMoveInLocation == null || mAdapter.getData() == null) {
            return;
        }
        //可移入量 = 库位的库容 - 库位库存数 - 该库位待移入数量
        int canMoveInQty = mMoveInLocation.getCanMoveInQty();
        if (canMoveInQty <= 0) {
            mTvMoveCountTips.setVisibility(View.VISIBLE);
            mTvMoveCountTips.setText("* 移入库位没有可用库容量！");
            mEtMoveCount.setEnabled(false);
            mBtnConfirm.setEnabled(false);
        } else {
            //可移出数量
            int canMoveOutQty = mMoveOutLocation.getCanMoveOutQtyWithOwner();
            mCanMoveQty = canMoveInQty > canMoveOutQty ? canMoveOutQty : canMoveInQty;
            mTvMoveCountTips.setVisibility(View.VISIBLE);
            if (mCanMoveQty == Integer.MAX_VALUE) {
                mTvMoveCountTips.setText("* 最多可以移入数量：无限制");
            } else {
                mTvMoveCountTips.setText("* 最多可以移入数量：" + mCanMoveQty);
            }
            mEtMoveCount.setEnabled(true);
            mBtnConfirm.setEnabled(true);
            mEtMoveCount.requestFocus();
        }
    }

    private void confirmClick() {
        if (!checkDataValid()) {
            mBtnConfirm.setEnabled(false);
            return;
        }
        showOperateConfirmDialog();
    }

    private boolean checkDataValid() {
        if (getCurrentWarehouse() == null) {
            showErrorTips("仓库信息获取失败！");
            return false;
        }
        if (mMoveOutLocation == null) {
            showErrorTips("出库信息获取失败！");
            return false;
        }
        if (mOperateGoods == null) {
            showErrorTips("商品信息获取失败！");
            return false;
        }
        if (mMoveInLocation == null) {
            showErrorTips("入库信息获取失败！");
            return false;
        }
        if (mCanMoveQty == 0) {
            showErrorTips("商品可移库数量为0");
            return false;
        }
        int moveQty = CommonUtil.formatStringToInt(mEtMoveCount.getText().toString().trim());
        if (moveQty == 0) {
            showErrorTips("请输入移库数量！");
            return false;
        }
        return true;
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    private void clearAllData() {
        mMoveOutLocation = null;
        mMoveInLocation = null;
        mOperateGoods = null;
        mCanMoveQty = 0;
        mGoodsLocaitonList.clear();
    }

    private void clearAllView() {
        clearAllData();
        mTvErrorTips.setVisibility(View.GONE);
        mEtMoveOutLocation.setText("");
        mEtGoodsBarcode.setText("");
        mEtMoveInLocation.setText("");
        mEtMoveCount.setText("");
        et_invStatusName.setText("");
        mTvMoveCountTips.setText("");
        mTvMoveCountTips.setVisibility(View.GONE);
        initGoodsView();
        mTvNoDataTips.setVisibility(View.VISIBLE);
        mListView.setVisibility(View.GONE);
        mBtnConfirm.setEnabled(false);
        mEtMoveOutLocation.requestFocus();
    }

    /**
     * 展示移库操作确认框
     */
    private void showOperateConfirmDialog() {
        if (mOperateConfirmDialog == null) {
            mOperateConfirmDialog = new RemindDialog(MoveInWarehouseActivity.this);
        }
        mOperateConfirmDialog.setTitle("确认");
        mOperateConfirmDialog.setContent(getOperateContent());
        mOperateConfirmDialog.setShowCancelButton();
        mOperateConfirmDialog.setListener(new RemindDialog.OnConfirmClickListener() {
            @Override
            public void onConfirmClick() {
                requestMoveOperate();
            }
        });
        mOperateConfirmDialog.show();
    }

    private String getOperateContent() {
        StringBuffer sb = new StringBuffer();
        sb.append("SKU 名称：" + mOperateGoods.getSpecName());
        sb.append("\n");
        sb.append("移出库位：" + mMoveOutLocation.getLocationName());
        sb.append("\n");
        sb.append("移入库位：" + mMoveInLocation.getLocationName());
        sb.append("\n");
        sb.append("移动数量：" + CommonUtil.formatStringToInt(mEtMoveCount.getText().toString().trim()));
        return sb.toString();
    }

    private void requestMoveOperate() {
        showLoadingDialog();
        IMoveOperate moveOperate = new MoveOperateImpl();
        int moveQty = CommonUtil.formatStringToInt(mEtMoveCount.getText().toString().trim());
        moveOperate.requestMoveOperate(mMoveOutLocation.getSelectedStatusBean().getInvStatusId(), getCurrentWarehouse().getId(), mMoveOutLocation.getLocationId(), mMoveInLocation.getLocationId(),
                String.valueOf(mOperateGoods.getSkuId()), moveQty, 0, "1", 3, mMoveOutLocation.getSelectedOwnerBean().getOwner(), mMoveOutLocation.getSelectedOwnerBean().getOwnertype(), new OnRequestCallback<String>() {
                    @Override
                    public void onFailedCallback(boolean isRequestCallback, final String errorMsg) {
                        super.onFailedCallback(isRequestCallback, errorMsg);
                        runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                dismissLoadingDialog();
                                showResultRemindDialog(false, errorMsg);
                            }
                        });
                    }

                    @Override
                    public void onSuccessCallback(String result, Object object) {
                        super.onSuccessCallback(result, object);
                        runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                dismissLoadingDialog();
                                showResultRemindDialog(true, "");
                            }
                        });
                    }
                });
    }

    /**
     * 展示库存状态选择框
     */
    private void showInvStatusNameSelector() {
        ListSelectorPpWindow<LocationListBean> locationSelector = new ListSelectorPpWindow<>(MoveInWarehouseActivity.this,
                R.drawable.shape_bg_edit_selected,
                et_invStatusName.getWidth(),
                locationListBeanList,
                new ListSelectorPpWindow.onItemSelectedListener() {
                    @Override
                    public void onItemSelected(Object item) {
                        LocationListBean locationListBean = ((LocationListBean) item);
                        mMoveOutLocation.setSelectedStatusBean(locationListBean);
                        et_invStatusName.setText(locationListBean.getInvStatusName());
                        calculateCanMoveQty();
                        if (TextUtils.isEmpty(mEtMoveInLocation.getText().toString())) {
                            CommonUtil.requestFocusAndNoClearText(mEtMoveInLocation);
                        } else {
                            CommonUtil.requestFocusAndNoClearText(mEtMoveCount);
                        }
                        mAdapter.notifyDataSetChanged();
                    }
                });
        locationSelector.showAsDropDown(et_invStatusName, 0, 10);
    }

    /**
     * 展示结果提示框
     *
     * @param isSuccess 是否成功
     * @param errorMsg  错误信息
     */
    private void showResultRemindDialog(final boolean isSuccess, String errorMsg) {
        if (mResultRemindDialog == null) {
            mResultRemindDialog = new RemindDialog(MoveInWarehouseActivity.this);
        }
        mResultRemindDialog.setShowStatusView(isSuccess ? R.mipmap.icon_operate_success : R.mipmap.icon_operate_failed);
        mResultRemindDialog.setNoTitle();
        mResultRemindDialog.setContent(isSuccess ? "移库成功" : ("移库失败，原因：" + errorMsg));
        if (isSuccess) {
            mResultRemindDialog.autoDismiss(true);
            mResultRemindDialog.autoDismissDelay(2000);
        } else {
            mResultRemindDialog.autoDismiss(false);
        }
        mResultRemindDialog.show();
        if (isSuccess) {
            //操作成功： 隐藏所有按钮，并且2S后自动关闭
            clearAllView();
            mResultRemindDialog.setAllButtonVisible(false);
        } else {
            mResultRemindDialog.setAllButtonVisible(true);
        }
    }
}
